(function () {
    'use strict';

    angular
    .module('app')
    .factory('APIConsigneeService', APIConsigneeService);

    APIConsigneeService.$inject = ['$http', '$q', '$timeout', 'CacheFactory', 'ENUM'];

    function APIConsigneeService($http, $q, $timeout, CacheFactory, ENUM) {

        var service = new APIEndpoint( $http, $q, $timeout, CacheFactory, 'APIConsigneeService' );

        service.getAddList = function(params) {
            return this.fetch( '/weixin/user/getAddList', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.addAddress = function(params) {
            return this.fetch( '/weixin/user/addAddress', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.deleteAdd = function(params) {
            return this.fetch( '/weixin/user/deleteAdd', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? true : false;
            });
        };

        service.setDefault = function(params) {
            return this.fetch( '/weixin/user/setDefaultAdd', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? true : false;
            });
        };

        return service;
    }

})();
